﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;

namespace Eugenhome.Atrium.Rss
{
    /// <summary>
    /// 
    /// </summary>
    public class Rss
    {
        /// <summary></summary>
        public DateTime PubDate { get { return _pubDate; } set { _pubDate = value; } }
        /// <summary></summary>
        public string Title { get; private set; }
        /// <summary></summary>
        public string Link { get; private set; }
        /// <summary></summary>
        public string Description { get; private set; }
        /// <summary></summary>
        private DateTime _pubDate = DateTime.MinValue;

        /// <summary></summary>
        public int Hashcode { get; private set; }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="node"></param>
        public Rss(XmlNode node)
        {
            Title = node.SelectSingleNode("title") != null ? node.SelectSingleNode("title").InnerText : "[nicht gesetzt]";
            Link = node.SelectSingleNode("link") != null ? node.SelectSingleNode("link").InnerText : "[nicht gesetzt]";
            Description = node.SelectSingleNode("description") != null ? node.SelectSingleNode("description").InnerText : "";
            //PubDate = node.SelectSingleNode("pubDate").InnerText;
            //Hashcode = Link.GetHashCode();

            DateTime.TryParse(node.SelectSingleNode("pubDate").InnerText, out _pubDate);
        }
    }
}
